package com.chengjue.transaction.controller;

import com.chengjue.transaction.anno.UserAccess;
import com.chengjue.transaction.pojo.SysUser;
import com.chengjue.transaction.pojo.SysUserExample;
import com.chengjue.transaction.service.SysUserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 描述:
 *
 * @author Kipeng Huang
 * @create 2018-02-26 下午8:23
 */
@RestController
public class UserController {
	@Autowired
	SysUserService sysUserService;

	@GetMapping("/user/{id}")
	@UserAccess(needLogin = true)
	public SysUser getUser(@PathVariable("id") Long id) {
		return sysUserService.selectByPrimaryKey(id);
	}


	@GetMapping("/user/{page}/{size}")
	public List<SysUser> getUser(@PathVariable Integer page, @PathVariable Integer size){
		SysUserExample example = new SysUserExample();
		//example.createCriteria().andUserIdEqualTo(Long.valueOf(1));
		return sysUserService.selectByExample(example);
	}


}
